﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="MonkeyWarranty.Web.WarrantyTickets.List" %>
<%@ Import Namespace="Resources" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <title><%= GlobalStrings.WarrantyTickets %></title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <p>
        <strong><a href="List.aspx" class="a-selected"><%= GlobalStrings.Ticket %></a></strong>&nbsp;|&nbsp;
        <a href="WaitingWarranty.aspx"><%= GlobalStrings.WaitingWarranty %></a>&nbsp;|&nbsp;
        <a href="ProcessWarranty.aspx"><%= GlobalStrings.ProcessWarranty %></a>&nbsp;|&nbsp;
        <a href="ReceivedProducts.aspx"><%= GlobalStrings.ProcessReceivedProducts %></a>&nbsp;|&nbsp;
        <a href="LendProducts.aspx"><%= GlobalStrings.ProcessLendProducts %></a>
    </p>
    <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
        <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
            <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tabs-1"><%= GlobalStrings.Received %></a></li>
            <li class="ui-state-default ui-corner-top"><a href="#tabs-2"><%= GlobalStrings.Processing %></a></li>
            <li class="ui-state-default ui-corner-top"><a href="#tabs-3"><%= GlobalStrings.Completed %></a></li>
        </ul>
        <div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
            <div id="NewWarrantyTicketsTableContainer"></div>
        </div>
        <div id="tabs-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
            <div id="ProcessingWarrantyTicketsTableContainer"></div>
        </div>
        <div id="tabs-3" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
            <div id="CompletedWarrantyTicketsTableContainer"></div>
        </div>
    </div>
    

    <p><input type="button" value="<%= GlobalStrings.AddNew %>" onclick=" javascript:window.location = 'New.aspx'; " /></p>
    
    <script type="text/javascript">
        $(document).ready(function() {
            $("#tabs").tabs();
            LoadNewTickets();
            LoadProcessingTickets();
            LoadCompletedTickets();
        });
    </script>
    
    <script type="text/javascript">
        function LoadNewTickets() {
            $('#NewWarrantyTicketsTableContainer').jtable({
            //title: '<%= GlobalStrings.InstantTickets %>',
                paging: true,
                pageSize: 15,
                sorting: true,
                defaultSorting: 'CreatedDate DESC',
                actions: {
                    listAction: 'List.aspx/TicketListByFilter',
                    deleteAction: 'List.aspx/DeleteTicket'
                },
                fields: {
                    Id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    Code: {
                        title: '<%= GlobalStrings.TicketNumber %>',
                        width: '5%',
                        display: function(data) {
                            return '<a href="Edit.aspx?id=' + data.record.Id + '">' + data.record.Code + '<a/>';
                        }
                    },
                    CreatedDate: {
                        title: '<%= GlobalStrings.ReceivedDate %>',
                        type: 'date',
                        displayFormat: 'dd/mm/yy',
                        width: '7%'
                    },
                    DeliveryDate: {
                        title: '<%= GlobalStrings.WishDate %>',
                        type: 'date',
                        displayFormat: 'dd/mm/yy',
                        width: '7%'
                    },
                    CreatedEmployeeName: { title: '<%= GlobalStrings.ReceivedEmployee %>' },
                    ReceivedFromName: { title: '<%= GlobalStrings.ReceivedFrom %>' },
                    DealerEmployeeName: { title: '<%= GlobalStrings.DealerEmployeeName %>' },
                    CustomerName: { title: '<%= GlobalStrings.Customers %>' },
                    Phone: { title: '<%= GlobalStrings.Phone %>', width: '7%' },
                    Address: { title: '<%= GlobalStrings.Address %>' },
                    TicketContent: { title: '<%= GlobalStrings.Content %>', sorting: false },
                    Edit: {
                        title: '',
                        sorting: false,
                        width: '1%',
                        display: function(data) {
                            return '<input class="jtable-command-button jtable-edit-command-button" onclick="javascript:window.location=\'Edit.aspx?id=' + data.record.Id + '\';" />';
                        }
                    }
                }
            });

            $('#NewWarrantyTicketsTableContainer').jtable('load', { status: 1 });
        }

        function LoadProcessingTickets() {
            $('#ProcessingWarrantyTicketsTableContainer').jtable({
                paging: true,
                pageSize: 15,
                sorting: true,
                defaultSorting: 'CreatedDate DESC',
                actions: {
                    listAction: 'List.aspx/TicketListByFilter',
                    deleteAction: 'List.aspx/DeleteTicket'
                },
                fields: {
                    Id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    Code: {
                        title: '<%= GlobalStrings.TicketNumber %>',
                        width: '5%',
                        display: function(data) {
                            return '<a href="Edit.aspx?id=' + data.record.Id + '">' + data.record.Code + '<a/>';
                        }
                    },
                    CreatedDate: {
                        title: '<%= GlobalStrings.ReceivedDate %>',
                        type: 'date',
                        displayFormat: 'dd/mm/yy',
                        width: '7%'
                    },
                    DeliveryDate: {
                        title: '<%= GlobalStrings.WishDate %>',
                        type: 'date',
                        displayFormat: 'dd/mm/yy',
                        width: '7%'
                    },
                    CreatedEmployeeName: { title: '<%= GlobalStrings.ReceivedEmployee %>' },
                    ReceivedFromName: { title: '<%= GlobalStrings.ReceivedFrom %>' },
                    DealerEmployeeName: { title: '<%= GlobalStrings.DealerEmployeeName %>' },
                    CustomerName: { title: '<%= GlobalStrings.Customers %>' },
                    Phone: { title: '<%= GlobalStrings.Phone %>', width: '7%' },
                    Address: { title: '<%= GlobalStrings.Address %>' },
                    TicketContent: { title: '<%= GlobalStrings.Content %>', sorting: false },
                    Edit: {
                        title: '',
                        sorting: false,
                        width: '1%',
                        display: function(data) {
                            return '<input class="jtable-command-button jtable-edit-command-button" onclick="javascript:window.location=\'Edit.aspx?id=' + data.record.Id + '\';" />';
                        }
                    }
                }
            });

            $('#ProcessingWarrantyTicketsTableContainer').jtable('load', { status: 2 });
        }

        function LoadCompletedTickets() {
            $('#CompletedWarrantyTicketsTableContainer').jtable({
                paging: true,
                pageSize: 15,
                sorting: true,
                defaultSorting: 'CreatedDate DESC',
                actions: {
                    listAction: 'List.aspx/TicketListByFilter',
                    deleteAction: 'List.aspx/DeleteTicket'
                },
                fields: {
                    Id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    Code: {
                        title: '<%= GlobalStrings.TicketNumber %>',
                        width: '5%',
                        display: function(data) {
                            return '<a href="Edit.aspx?id=' + data.record.Id + '">' + data.record.Code + '<a/>';
                        }
                    },
                    CreatedDate: {
                        title: '<%= GlobalStrings.ReceivedDate %>',
                        type: 'date',
                        displayFormat: 'dd/mm/yy',
                        width: '7%'
                    },
                    DeliveryDate: {
                        title: '<%= GlobalStrings.WishDate %>',
                        type: 'date',
                        displayFormat: 'dd/mm/yy',
                        width: '7%'
                    },
                    CreatedEmployeeName: { title: '<%= GlobalStrings.ReceivedEmployee %>' },
                    ReceivedFromName: { title: '<%= GlobalStrings.ReceivedFrom %>' },
                    DealerEmployeeName: { title: '<%= GlobalStrings.DealerEmployeeName %>' },
                    CustomerName: { title: '<%= GlobalStrings.Customers %>' },
                    Phone: { title: '<%= GlobalStrings.Phone %>', width: '7%' },
                    Address: { title: '<%= GlobalStrings.Address %>' },
                    TicketContent: { title: '<%= GlobalStrings.Content %>', sorting: false },
                    Edit: {
                        title: '',
                        sorting: false,
                        width: '1%',
                        display: function(data) {
                            return '<input class="jtable-command-button jtable-edit-command-button" onclick="javascript:window.location=\'Edit.aspx?id=' + data.record.Id + '\';" />';
                        }
                    }
                }
            });

            $('#CompletedWarrantyTicketsTableContainer').jtable('load', { status: 3 });
        }
    </script>
</asp:Content>